home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Graphics Unleashed
/
PC Graphics Unleashed.iso
/
ch10
/
raw2pov.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-05-16
|
1KB
|
67 lines
///////////////////////////////////////////
//
// RAW TO POV 2.0+ CONVERTER RAW2POV.C
//
//////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
void main(int argc, char *argv[]) {
FILE *infile, *outfile;
float x1, y1, z1,
x2, y2, z2,
x3, y3, z3;
if(argc < 2) {
printf("Usage: RAW2POV inputfile outputfile\n");
exit(1);
}
if ((infile = fopen(argv[1], "rt")) == NULL) {
printf("Can't open %s!\n",argv[1]);
exit(1);
}
if ((outfile = fopen(argv[2], "wt")) == NULL) {
printf("Can't open %s!\n",argv[2]);
exit(1);
}
fprintf(outfile," union {\n");
while (!feof(infile)) {
if ((fscanf(infile,"%f",&x1) > 0) &&
(fscanf(infile,"%f",&y1) > 0) &&
(fscanf(infile,"%f",&z1) > 0) &&
(fscanf(infile,"%f",&x2) > 0) &&
(fscanf(infile,"%f",&y2) > 0) &&
(fscanf(infile,"%f",&z2) > 0) &&
(fscanf(infile,"%f",&x3) > 0) &&
(fscanf(infile,"%f",&y3) > 0) &&
(fscanf(infile,"%f",&z3) > 0)) {
fprintf(outfile," triangle {<%g, %g, %g>, ",x1,y1,z1);
fprintf(outfile,"<%g, %g, %g>, ",x2,y2,z2);
fprintf(outfile,"<%g, %g, %g>}\n",x3,y3,z3);
}
}
fprintf(outfile," pigment {Red}\n }\n");
fclose(infile);
fclose(outfile);
}